home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / os2 / srefv112.zip / STATUS.80 < prev    next >
Text File  |  1996-05-10  |  6KB  |  155 lines

  1. /* This is the STATUS demo of SRE-FILTER's server side proceessing
  2.  
  3. Use STATUS.HTM to invoke this routine.
  4. */
  5.  
  6. status:
  7. parse arg  ddir, tempfile, reqstrg,list,verb ,uri,user, basedir ,workdir,privset,macro_info
  8. list=translate(list, ' ', '+'||'090a0d'x)  /* Whitespace, etc. */
  9.  
  10. /* Information will be returned in a temporary file, whose name
  11. is provided in the tempfile variable.
  12. Note that it's a good idea to start your HTML documents with a dtd doctype statement
  13.  */
  14.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 2.0//EN">'
  15.  
  16.         call lineout tempfile, "<html><head><title>Results from STATUS request</title>"
  17.         call lineout tempfile, "</head><body>"
  18.         call lineout tempfile,' <h2>Results from  Status Request </h2>'
  19.  
  20.         call lineout tempfile,' <h3>The arguments recieved by STATUS </h3> '
  21.  
  22.         call lineout tempfile,' <dl> '
  23.  
  24.         call lineout tempfile,' <dt>  DDIR = <code>' ddir '</code> '
  25.         call lineout tempfile,' <dd>  The "data directory" (where your HTML documents should be) '
  26.         call lineout tempfile,' <dt>  TEMPFILE = <code>' tempfile ' </code> '
  27.         call lineout tempfile,' <dd> The "temporary file" (used to build this response)'
  28.  
  29.         call lineout tempfile,' <dt>  REQSTRG = <code>' reqstrg ' </code> '
  30.         call lineout tempfile,' <dd>  The request string '
  31.  
  32.  
  33.         call lineout tempfile,' <dt>  LIST = <code>' list ' </code> '
  34.         call lineout tempfile,' <dd> The parameters: '
  35.         call lineout tempfile, '<br> ... if POST method, from the "body" of the request '
  36.         call lineout tempfile,' <br> ... if GET method ,  from after the "?" in the request string.  '
  37.  
  38.         call lineout tempfile,' <dt>  VERB = <code>' VERB ' </code> '
  39.         call lineout tempfile,' <dd>  The HTTP method '
  40.  
  41.         call lineout tempfile,' <dt>  URI = <code>' URI ' </code> '
  42.         call lineout tempfile,' <dd> The full URI '
  43.  
  44.         call lineout tempfile,' <dt> USER = <code>' user ' </code> '
  45.         call lineout tempfile,' <dd> USERS ip addrees '
  46.  
  47.         call lineout tempfile,' <dt>  BASEDIR = <code>' basedir ' </code> '
  48.         call lineout tempfile,' <dd> The "working directory" (where SRE-FILTER and GoServe live) '
  49.  
  50.         call lineout tempfile,' <dt>  WORKDIR = <code>' workdir ' </code> '
  51.         call lineout tempfile,' <dd>  Temporary working files area '
  52.  
  53.  
  54.  
  55.          call lineout tempfile,'</dl>'
  56.  
  57.  
  58. /* Read the "header" -- and display the results */
  59.        'READ HEADER VAR FOO '
  60.          call lineout tempfile,' <h3> The Request Header </h3> '
  61.  
  62.         call lineout tempfile,' <dd> <blockquote> <pre>' foo  '</pre> </blockquote>'
  63.  
  64.         call lineout tempfile,' <h3> Some User & Server Info </h3> '
  65.  
  66.  
  67. /* This section demonstrates the use of some GOSERVE functions */
  68.    cname=clientname()
  69.    caddr=extract('CLIENTADDR')
  70.    ssoft=server()
  71.    sname=servername()
  72.    saddr=extract('SERVERADDR')
  73.    sport=extract('SERVERPORT')
  74.  
  75.    call lineout tempfile,' <ul> '
  76.    call lineout tempfile,' <li> Client ip address:  <code>' caddr '</code>'
  77.    call lineout tempfile,' <li> Client name:  <code>' cname '</code>'
  78.    call lineout tempfile,' <li> Server ip address: <code>' saddr '</code>'
  79.    call lineout tempfile,' <li> Server port:  <code>' sport '</code>'
  80.  
  81.    call lineout tempfile,' <li> Server name:  <code>' sname '</code>'
  82.    call lineout tempfile, ' <li> Server software:  <code>' ssoft '</code>'
  83.    call lineout tempfile,' <li> Your privileges are: <tt> ' privset ' </tt>'
  84.    call lineout tempfile,' </ul> '
  85.  
  86. /* superusers and inhouse users get to see sre-filter's parameters,
  87. if desired (by pressing a link to filtinst */
  88.  
  89.   if wordpos('SUPERUSER',privset)=0 then signal getuse
  90.   call lineout tempfile,' <h3> SRE-FILTER settings </h3> '
  91.   call lineout tempfile,' <br>   Do you want to see the  <A href='
  92.   call lineout tempfile,' "/filtinst?todo=show">current settings of SRE-FILTER'"'s parameters</A>? <br>"
  93.  
  94.  
  95. getuse: nop
  96. /* get some "intensity of use " statistics */
  97.  reptime=extract('RESPONSETIME')
  98.  numtrans=extract('TRANSACTIONS')
  99.  whenstart=extract('LASTSTART')
  100.  nclients=extract('CLIENTS')
  101.  
  102.    call lineout tempfile,' <h3> Use Statistics </h3> '
  103.    call lineout tempfile,'<BR> GoServe started: ' whenstart
  104.  
  105.    call lineout tempfile,'<BR> # of transactions ' numtrans  ', avg. reponsetime = 'reptime ' sec. '
  106.  
  107.    call lineout tempfile,'<BR> Current # of clients = ' nclients
  108.  
  109.  
  110.  
  111. /* Use the HOST function -- demonstrates the use of external calls */
  112.  
  113. /* but first "parse" the parameter list, and store in a simple stem variable */
  114.   m=0
  115.   do until list=""
  116.     parse var list opt1 '&' list
  117.     m=m+1
  118.     parse var opt1 optname.m '=' optvalue.m
  119.   end
  120.   optname.0=m
  121.  
  122. /* see if one of the opts is "getip" */
  123.    chkip=0 ;
  124.    do mm=1 to optname.0
  125.       if translate(optname.mm)='GETIP' then do
  126.          chkip=optvalue.mm
  127.          leave
  128.       end
  129.   end
  130.  
  131. /* if we found a GETIP, and got it's value, then lookit up */
  132.   if chkip<>0 & chkip<>"" then do
  133. /* Note use of the address cmd xxx to call a OS/2 level command  */
  134.     do queued(); pull .; end                   /* flush */
  135.     address cmd '@host' chkip '| rxqueue'     /* execute the command */
  136.     parse pull hostresult                      /* get result */
  137.  
  138.     call lineout tempfile,' <h3> Look up address </h3> '
  139.  
  140.     call lineout tempfile,' <pre> ' hostresult ' </pre>'
  141.   end
  142.  
  143.  
  144.  
  145.  
  146. /* all done, write final end-of-html elements */
  147.   call lineout tempfile,'<body> </html>'
  148.  
  149. /* Return a "completion code" -- SRE-FILTER will do the rest */
  150. /* Note: a VAR (and sometimes a STRING) completion code
  151.        is often used instead of FILE ..   TEMPFILE */
  152.      return 'FILE ERASE TYPE text/html NAME' tempfile
  153.  
  154.  
  155.